﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sunboxsoft.WinForm
{
    public class ActionNodeCollection
    {
        private List<ActionNode> _roots = new List<ActionNode>();

        public List<ActionNode> Roots
        {
            get
            {
                return _roots;
            }
        }

        public int Count
        {
            get
            {
                return _roots.Count;
            }
        }

        public ActionNode this[int index]
        {
            get
            {
                return _roots[index];
            }
        }

        public ActionNode RegisterAction(ActionNode action)
        {
            _roots.Add(action);
            return action;
        }

        public ActionNode RegisterAction(string name, string caption)
        {
            ActionNode node = new ActionNode(name, caption);
            _roots.Add(node);
            return node;
        }

        public ActionNode RegisterAction(string name, string caption, Action<object, object> clickCallback)
        {
            ActionNode node = new ActionNode(name, caption, clickCallback);
            _roots.Add(node);
            return node;
        }

        public ActionNodeCollection AddAction(ActionNode action)
        {
            _roots.Add(action);
            return this;
        }

        public ActionNodeCollection AddAction(string name, string caption)
        {
            ActionNode node = new ActionNode(name, caption);
            _roots.Add(node);
            return this;
        }

        public ActionNodeCollection AddAction(string name, string caption, Action<object, object> clickCallback)
        {
            ActionNode node = new ActionNode(name, caption, clickCallback);
            _roots.Add(node);
            return this;
        }
    }
}
